package com.eorchis.module.trainingneeds.ui.commond;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.beanutils.BeanUtils;
import org.codehaus.jackson.map.ObjectMapper;

import com.eorchis.core.page.commond.SortInfoBean;
import com.eorchis.core.ui.commond.IQueryCommond;
import com.eorchis.core.ui.commond.impl.BasePageQueryCommond;

/**
 * Title: QuestionnaireCommond<br>
 * Description: 培训需求问卷表Commond<br>
 * Company: GoldGov<br>
 * Copyright @ 2012 GoldGov .All rights reserved.<br>
 * @author HuangTF
 * @createDate 2014-02-07
 * @version $Revision$
 */
public class QuestionnaireQueryCommond extends BasePageQueryCommond implements IQueryCommond {

	private String[] searchQuestionnaireIds;//问卷ids
	private String searchQuestionnaireId;//问卷id
	private String searchQuestionnaireName;//问卷名称
	private String searchQuestionnaireType;//问卷类型
	private Integer searchSurveyType;//调查方式(1:电子问卷)
	private String searchQuestionnaireExplain;//问卷说明
	private String searchBeginDate;//开始时间
	private String searchEndDate;//结束时间
	private String userId;//创建人id
	private String userName;//创建人名称
	private String deptId;//创建单位id
	private String deptName;//创建单位名称
	private Integer publishState;//发布状态(1:已发布 2:未发布)
	private Integer activeState;//活动状态
	private String questionType;//试题题型
	
	public String getQuestionType() {
		return questionType;
	}
	public void setQuestionType(String questionType) {
		this.questionType = questionType;
	}
	public String getSearchQuestionnaireExplain() {
		return searchQuestionnaireExplain;
	}
	public void setSearchQuestionnaireExplain(String searchQuestionnaireExplain) {
		this.searchQuestionnaireExplain = searchQuestionnaireExplain;
	}
	public String[] getSearchQuestionnaireIds() {
		return searchQuestionnaireIds;
	}
	public void setSearchQuestionnaireIds(String[] searchQuestionnaireIds) {
		this.searchQuestionnaireIds = searchQuestionnaireIds;
	}
	public String getSearchQuestionnaireId() {
		return searchQuestionnaireId;
	}
	public void setSearchQuestionnaireId(String searchQuestionnaireId) {
		this.searchQuestionnaireId = searchQuestionnaireId;
	}
	public String getSearchQuestionnaireName() {
		return searchQuestionnaireName;
	}
	public void setSearchQuestionnaireName(String searchQuestionnaireName) {
		this.searchQuestionnaireName = searchQuestionnaireName;
	}
	public String getSearchQuestionnaireType() {
		return searchQuestionnaireType;
	}
	public void setSearchQuestionnaireType(String searchQuestionnaireType) {
		this.searchQuestionnaireType = searchQuestionnaireType;
	}
	public Integer getSearchSurveyType() {
		return searchSurveyType;
	}
	public void setSearchSurveyType(Integer searchSurveyType) {
		this.searchSurveyType = searchSurveyType;
	}
	public String getSearchBeginDate() {
		return searchBeginDate;
	}
	public void setSearchBeginDate(String searchBeginDate) {
		this.searchBeginDate = searchBeginDate;
	}
	public String getSearchEndDate() {
		return searchEndDate;
	}
	public void setSearchEndDate(String searchEndDate) {
		this.searchEndDate = searchEndDate;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getDeptId() {
		return deptId;
	}
	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	public Integer getPublishState() {
		return publishState;
	}
	public void setPublishState(Integer publishState) {
		this.publishState = publishState;
	}
	public Integer getActiveState() {
		return activeState;
	}
	public void setActiveState(Integer activeState) {
		this.activeState = activeState;
	}
	
	
	/**
	 * EXT 页面排序
	 */
	private SortInfoBean sortInfo = null;
	
	/**
	 * 获取排序内容
	 * 
	 * @return
	 * @author HuangS
	 * @date Jul 20, 2012
	 */
	public SortInfoBean getSortInfos() {
		return this.sortInfo;
	}

	/**
	 * 设置排序内容
	 * 
	 * @param sort
	 * @author HuangS
	 * @date Jul 25, 2012
	 */
	@SuppressWarnings("unchecked")
	public void setSort(String sort) {
		if (sort != null && !"".equals(sort)) {
			sortInfo = new SortInfoBean();
			ObjectMapper objectMapper = new ObjectMapper();
			try {
				List<LinkedHashMap<String, Object>> list = objectMapper.readValue(sort, List.class);
				for (int i = 0; i < list.size(); i++) {
					Map<String, Object> map = list.get(i);
					Set<String> set = map.keySet();
					for (Iterator<String> it = set.iterator(); it.hasNext();) {
						String key = it.next();
						BeanUtils.setProperty(sortInfo, key, map.get(key));
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
